@include('Home.head')



<body>

<div class="container" id="app">

    <header data-am-widget="header" class="am-header am-header-default my-header">

        {{--<div class="am-header-left am-header-nav am-dropdown"  data-am-dropdown>--}}

        {{--<a href="javascript:;" class="am-dropdown-toggle"  data-am-dropdown-toggle>--}}

        {{--<i class="am-header-icon am-icon-th-large"></i>--}}

        {{--</a>--}}

        {{--<div style="display:none">--}}



        {{--</div>--}}

        {{--<ul class="am-dropdown-content">--}}

        {{--<li><a href="#">关于我们</a></li>--}}

        {{--<li><a href="#">新闻中心</a></li>--}}

        {{--<li><a href="#">团购</a></li>--}}

        {{--<li><a href="#">商城</a></li>--}}

        {{--<li><a href="#">收银台</a></li>--}}

        {{--<li><a href="#">相册</a></li>--}}

        {{--<li><a href="#">视频</a></li>--}}

        {{--</ul>--}}

        {{--</div>--}}

        <h1 class="am-header-title">

            <a href="#title-link" class="">新人专区</a>

        </h1>

        {{--<div class="am-header-right am-header-nav">--}}

        {{--<a href="#right-link" class="">--}}

        {{--<i class="am-header-icon  am-icon-share-alt"></i>--}}

        {{--</a>--}}

        {{--</div>--}}

    </header>

    <!-- banner -->

    <div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{&quot;directionNav&quot;:false}'>

            <el-carousel>
                <el-carousel-item v-for="item in rotation">
                    <a v-on:click="jump(item.gid)" >
                        <img :src="item.goods_thumb" width="100%" height="100%">
                    </a>
                </el-carousel-item>
            </el-carousel>

    </div>

    <div class="am-cf am-g">

        <ul class="am-avg-sm-2 my-shop-product-list">

            <li v-for="val in goodsList">

                <div class="am-panel am-panel-default"  v-on:click="jump(val.id)">

                    <div class="am-panel-bd">

                        <img class="am-img-responsive" :src="val.goods_thumb" />

                        <h3><a href="#">@{{ val.goodsname }}</a></h3>

                        <div>

                            <span class="list-product-price-span2">￥@{{ val.rulingprice }}</span>

                            <span class="list-product-sorce-span">销量<br/>@{{ val.sold }}</span>
                            {{--<span class="list-product-sorce-span">销量<br/>162</span>--}}

                        </div>

                        <hr data-am-widget="divider" style="" class="am-divider am-divider-default am-cf"/>

                        <ol class="am-avg-sm-2 product-list-share">

                            {{--<li class="am-text-sm">积分：200</li>--}}

                            {{--<li><button class="am-btn am-btn-danger am-btn-xs index-addcart-btn">立即购买</button></li>--}}

                        </ol>

                    </div>

                </div>

            </li>

        </ul>

    </div>

    @include('Home.foot')

</div>

</body>

<script>

    var app = new Vue({

        el:"#app",

        data: {

            title:'报单商城',

            goodsList : [],
            rotation: [],
        },
		created: function () {
			this.initialize();
		},

        //事件

        methods: {

            //初始化 系统管理员列表

            initialize:function () {

                //获取商品数据

                $.post("/home/superShop/goods",{'_token':'{{csrf_token()}}',class:'select'},function (res) {
					// console.log(res);
                    if(res.code == 1){

                        app.goodsList = res.data;
						// console.log(res.data);
						// var datas = app.rotation;
						
						if (res.data.length > 3) {
							for (var i = 0; i < 3; i++) {
								var datas = {
									goods_thumb: '',
									gid: 0
								};
								datas.goods_thumb = app.goodsList[i].goods_thumb;
								datas.gid = app.goodsList[i].id;
								app.rotation.push(datas);
								
							}
						}else{
							for (var i = 0; i < res.data.length; i++) {
								var datas = {
									goods_thumb: '',
									gid: 0
								};
								datas.goods_thumb = app.goodsList[i].goods_thumb;
								datas.gid = app.goodsList[i].id;
								app.rotation.push(datas);
								
							}
						}
						// console.log(app.rotation);
                    } else {

                        layer.msg(res.data);

                    }

                });

            },

            //跳转

            jump:function (id) {

                window.location.href="/home/superShop/product?id="+id;

            },

            //获取url id

            obtain:function (val) {

                var query = window.location.search.substring(1);

                var vars = query.split("&");

                for (var i=0;i<vars.length;i++) {

                    var pair = vars[i].split("=");

                    if(pair[0] == val){

                        return pair[1];

                    }

                }

            },

        },

        //自动执行

        mounted: function () {

            // this.initialize();

        },

    })

</script>

</html>

